//
//  DataManager.m
//  NetworkMudleDemo
//
//  Created by 马晨曦 on 2019/5/13.
//  Copyright © 2019 VergilMa. All rights reserved.
//

#import "DataManager.h"
#import "AFNetworking.h"
@implementation DataManager
- (NSDictionary *)fetchDataWithConverter:(id<ConverterProtocol>)converter{
    if (!converter) {
        return @{@"key":@"value"};
    }else{
        return [converter convertDataWithManager:self];
    }
}
- (void)refreshDataWithType:(DataType)dataType{
    // 执行网络请求
    switch (dataType) {
        case dataTypeDef:
            self.netData = @"我是数据"; //json
            break;
        case dataTypeA:
            self.netData = @"我是数据A";
            break;
        case dataTypeB:
            self.netData = @"我是数据B";
            break;
        default:
            break;
    }
    
    /*
    [[AFHTTPSessionManager manager] GET:nil parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        //
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        //
        self.netData = @"我是数据";
    }];
     */
    
    if ([self.delegate respondsToSelector:@selector(dataManagerDidSuccess:)]) {
        [self.delegate dataManagerDidSuccess:self];
    }
}

@end
